
public class queue<T> {
	private Node<T> start;
	private Node<T> end;
	public queue(){
		this.start = null;
		this.end = null;
	}
	boolean isEmpty(){
		return this.start == null;
	}
	public void insert(T toInsert){
		Node<T> pos = new Node<T>(toInsert);
		if (this.isEmpty()){
			this.start = pos;
			this.end = pos;
			return;
		}
		if (this.start.getNext() == null)
			this.start.setNext(pos);
		this.end.setNext(pos);
		this.end = this.end.getNext();
	}
	public T remove(){
		Node<T> pos = this.start;
		this.start = this.start.getNext();
		return pos.getInfo();
	}
	public T head(){
		return this.start.getInfo();
	}
	public int length(){
		if (this.isEmpty())
			return 0;
		int i=1;
		for (Node<T> pos = start; pos.getNext() != null; pos = pos.getNext())
			i++;	
		return (i);
	}
	public String toString(){
		String s="[";
		Node<T> pos = start;
		while (pos != null) {
			s += pos.getInfo();
			pos = pos.getNext();
			if (pos != null) s += ", ";
		}
		s += "]";
		return s;
	}
}
